package com.mayikt.days06;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @ClassName Test001
 * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
 * @Version V1.0
 **/
public class Test001 implements Callable<String> {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        // 桌面、移动开发
        FutureTask<String> futureTask = new FutureTask<>(new Test001());
        new Thread(futureTask).start();
        String s = futureTask.get();
        System.out.println("获取返回结果>:"+s);
    }

    @Override
    public String call() throws Exception {
        try {
            Thread.sleep(3000);
            System.out.println(Thread.currentThread().getName() + ",发送短信完成..");
            return "发送短信完成.";
        } catch (Exception e) {
            return "发送短信失败.";
        }
    }
}
